package com.shuzijun.leetcode.editor.cn;
public class BinarySearch{
    public static void main(String[] args) {
         Solution solution = new BinarySearch().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int search(int[] nums, int target) {
        int low = 0;
        int high = nums.length-1;
        while (low <= high){
            int mid = (low + high) / 2;
            if (nums[mid] == target){
                return mid;
            } else if (nums[mid] < target) {
                low = mid+1;
            }else {
                high = mid-1;
            }
        }
        return -1;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}